cmake_minimum_required(VERSION 3.11)
project(sensor)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()
include_directories(
  include
  ${Boost_INCLUDE_DIRS}
  ${JSONCPP_INCLUDE_DIRS}
)
aux_source_directory(src SRC_LISTS)

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(ament_index_cpp REQUIRED)

# 查找JSON库
find_package(PkgConfig REQUIRED)
pkg_check_modules(JSONCPP REQUIRED jsoncpp)
# 创建可执行文件
add_executable(sensor src/sensor.cpp src/serial.cpp)
ament_target_dependencies(sensor rclcpp std_msgs sensor_msgs ament_index_cpp)
# 链接库
target_link_libraries(sensor
  ${JSONCPP_LIBRARIES}
)
# 安装可执行文件
install(TARGETS
  sensor
  DESTINATION lib/${PROJECT_NAME})
  
install(DIRECTORY launch config
  DESTINATION share/${PROJECT_NAME}
) 

ament_package()
